package com.common.library.retrofit;

import com.common.library.okhttp.OkHttpManager;

import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;


public class RetrofitHelper {

    private static RetrofitHelper instance;
    private Retrofit retrofit;
    //    private static final String BASE_URL = "http://10.21.5.25:8080/pvcm/";
    private static final String BASE_URL = "http://222.211.83.186:8080/pvcm/";
//    public static final String BASE_URL = "http://222.211.83.186:8080/bofscti/";
    OkHttpClient okHttpClient = OkHttpManager.getInstance();

    private RetrofitHelper() {
        init();
    }

    public static RetrofitHelper getInstance() {
        if (instance == null) {
            instance = new RetrofitHelper();
        }
        return instance;
    }

    private void init() {
        retrofit = new Retrofit.Builder()
                .client(okHttpClient)
                .baseUrl(BASE_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .build();
    }

    public Retrofit getRetrofit() {
        return retrofit;
    }
}
